package cn.dyw.cloudmusic.dao;

import cn.dyw.cloudmusic.entity.Al;
import cn.dyw.cloudmusic.music.vo.Songs;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AlMapper {
    /**
     */
    @Delete({
        "delete from al",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    /**
     */
    @Insert({
        "insert into al (id, music_id, ",
        "name, pic_url, pic_str, ",
        "pic)",
        "values (#{id,jdbcType=VARCHAR}, #{musicId,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{picStr,jdbcType=VARCHAR}, ",
        "#{pic,jdbcType=VARCHAR})"
    })
    int insert(Al record);

    /**
     */
    @Insert({
            "insert ignore al (id, music_id, ",
            "name, pic_url, pic_str, ",
            "pic)",
            "values (#{al.id,jdbcType=VARCHAR}, #{songs.id,jdbcType=VARCHAR}, ",
            "#{al.name,jdbcType=VARCHAR}, #{al.picUrl,jdbcType=VARCHAR}, #{al.picStr,jdbcType=VARCHAR}, ",
            "#{al.pic,jdbcType=VARCHAR})"
    })
    int insertVo(@Param("al") cn.dyw.cloudmusic.music.vo.Al al, @Param("songs") Songs songs);

    int insertList(@Param("als") List<cn.dyw.cloudmusic.music.vo.Al> als, @Param("songs") Songs songs);

    /**
     */
    int insertSelective(Al record);

    /**
     */
    @Select({
        "select",
        "id, music_id, name, pic_url, pic_str, pic",
        "from al",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("cn.dyw.cloudmusic.dao.AlMapper.BaseResultMap")
    Al selectByPrimaryKey(String id);

    /**
     */
    int updateByPrimaryKeySelective(Al record);

    /**
     */
    @Update({
        "update al",
        "set music_id = #{musicId,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "pic_url = #{picUrl,jdbcType=VARCHAR},",
          "pic_str = #{picStr,jdbcType=VARCHAR},",
          "pic = #{pic,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Al record);
}